home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / animExportOptions.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  16.1 KB  |  581 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  August 26, 1998
  22. //  Author:         cdt
  23. //
  24. //  Description:
  25. //
  26. //  Input Arguments:
  27. //
  28. //  Return Value:
  29. //
  30.  
  31. global proc animExportSetup(string $nextOptions[])
  32. //
  33. //    Description:
  34. //        Takes a string array containing an option keyword and its argument.
  35. //        This is used to set the copyKey widgets.
  36. //
  37. {
  38.     string $kCopyKeyWhichRange = "whichRange";
  39.     string $kCopyKeyRange = "range";
  40.     string $kCopyKeyOptions = "options";
  41.     string $kCopyKeyHierarchy = "hierarchy";
  42.     string $kCopyKeyControlPoints = "controlPoints";
  43.     string $kCopyKeyShapes = "shapes";
  44.     string $kCopyKeyHelpPictures = "helpPictures";
  45.     string $kCopyKeyUseChannelBox = "useChannelBox";
  46.  
  47.     if ($nextOptions[0] == $kCopyKeyWhichRange) {
  48.         // time range
  49.         //
  50.         int $timeRange = $nextOptions[1];
  51.         radioButtonGrp
  52.             -edit
  53.             -select $timeRange
  54.             timeRange;
  55.     } else if ($nextOptions[0] == $kCopyKeyRange) {
  56.         // start/end times
  57.         //
  58.         string $time = $nextOptions[1];
  59.         string $range[];
  60.         tokenize ($time, ":", $range);
  61.         float $start = float ($range[0]);
  62.         float $end = float ($range[1]);
  63.         floatFieldGrp -edit -value1 $start frameStart;
  64.         floatFieldGrp -edit -value1 $end frameEnd;
  65.     } else if ($nextOptions[0] == $kCopyKeyOptions) {
  66.         // -option
  67.         //
  68.         string $option = $nextOptions[1];
  69.         if ($option == "keys") {
  70.             radioButtonGrp
  71.                 -edit
  72.                 -select 1
  73.                 method;
  74.         }
  75.         else {
  76.             radioButtonGrp
  77.                 -edit
  78.                 -select 2
  79.                 method;
  80.         }
  81.     } else if ($nextOptions[0] == $kCopyKeyHierarchy) {
  82.         // -hierarchy
  83.         //
  84.         string $hierarchy = $nextOptions[1];
  85.         if ($hierarchy == "below") {
  86.             radioButtonGrp
  87.                 -edit
  88.                 -select 2
  89.                 hierarchy;
  90.         }
  91.         else {
  92.             radioButtonGrp
  93.                 -edit
  94.                 -select 1
  95.                 hierarchy;
  96.         }
  97.     } else if ($nextOptions[0] == $kCopyKeyControlPoints) {
  98.         // -controlPoints
  99.         //
  100.         int $controlPoints = $nextOptions[1];
  101.         checkBoxGrp -e -value1 $controlPoints controlPoints;
  102.     } else if ($nextOptions[0] == $kCopyKeyShapes) {
  103.         // -shape
  104.         //
  105.         int $shapes = $nextOptions[1];
  106.         checkBoxGrp -e -value1 $shapes shapes;
  107.     } else if ($nextOptions[0] == $kCopyKeyHelpPictures) {
  108.         // help images
  109.         //
  110.         int $pictures = $nextOptions[1];
  111.         checkBoxGrp -e -value1 $pictures helpPictures;
  112.     } else if ($nextOptions[0] == $kCopyKeyUseChannelBox) {
  113.         // use channel box attrs
  114.         //
  115.         int $boxAttrs = $nextOptions[1];
  116.         radioButtonGrp -e -select ( $boxAttrs + 1 ) channels;
  117.         if( $boxAttrs ) {
  118.             frameLayout -e -collapse yes attributesFrame;
  119.         } else {
  120.             frameLayout -e -collapse no attributesFrame;
  121.         }
  122.     }
  123.  
  124.     // Now get all the dependent widgets in the right 
  125.     // enabled/disabled/collapsed/expanded state
  126.     //
  127.     animExportWidgetsEnable;
  128.     animExportHelpPictures;
  129. }
  130.  
  131. global proc string animExportGetOpts() 
  132. //
  133. //    Description:
  134. //        Sets the opts string for all of the copyKey options.
  135. //
  136. {
  137.     string $opts;
  138.     string $kCopyKeyWhichRange = "whichRange";
  139.     string $kCopyKeyRange = "range";
  140.     string $kCopyKeyOptions = "options";
  141.     string $kCopyKeyHierarchy = "hierarchy";
  142.     string $kCopyKeyControlPoints = "controlPoints";
  143.     string $kCopyKeyShapes = "shapes";
  144.     string $kCopyKeyHelpPictures = "helpPictures";
  145.     string $kCopyKeyUseChannelBox = "useChannelBox";
  146.  
  147.     // which time range
  148.     //
  149.     int $whichRange = `radioButtonGrp -q -select timeRange`;
  150.     $opts += (";" + $kCopyKeyWhichRange + "=" + $whichRange);
  151.  
  152.     // -time
  153.     //
  154.     string $timeRange = 
  155.         string (`floatFieldGrp -query -value1 frameStart`) + ":" +
  156.         string (`floatFieldGrp -query -value1 frameEnd`);
  157.     $opts += (";" + $kCopyKeyRange + "=" + $timeRange);
  158.  
  159.     // -option
  160.     //
  161.     string $option;
  162.     if (`radioButtonGrp -query -select method` == 1) {
  163.         $option = "keys";
  164.     }
  165.     else {
  166.         $option = "curve";
  167.     }
  168.     $opts += (";" + $kCopyKeyOptions + "=" + $option);
  169.  
  170.     // -hierarchy
  171.     //
  172.     string $hierarchy;
  173.     int $selected = `radioButtonGrp -query -select hierarchy`;
  174.     if ($selected == 2) {
  175.         $hierarchy = "below";
  176.     }
  177.     else {
  178.         $hierarchy = "none";
  179.     }
  180.     $opts += (";" + $kCopyKeyHierarchy + "=" + $hierarchy);
  181.  
  182.     // -controlPoints
  183.     //
  184.     int $doControlPoints = `checkBoxGrp -query -value1 controlPoints`;
  185.     $opts += (";" + $kCopyKeyControlPoints + "=" + $doControlPoints);
  186.  
  187.     // -shapes
  188.     //
  189.     int $doShapes = `checkBoxGrp -query -value1 shapes`;
  190.     $opts += (";" + $kCopyKeyShapes + "=" + $doShapes);
  191.  
  192.     // help
  193.     //
  194.     int $helpPictures = `checkBoxGrp -query -value1 helpPictures`;
  195.     $opts += (";" + $kCopyKeyHelpPictures + "=" + $helpPictures);
  196.  
  197.     // use channel box attrs
  198.     //
  199.     int $useChannelBox = `radioButtonGrp -query -select channels`;
  200.     $useChannelBox--;
  201.     $opts += (";" + $kCopyKeyUseChannelBox + "=" + $useChannelBox);
  202.  
  203.     //    Since the copyKey command is fairly complex to assemble, the string 
  204.     //    passed to AnimExport will be long. The first section is the 
  205.     //    options in the option box. The second section is the copyKey command
  206.     //    without the -cb api call.
  207.     //
  208.     //    Effectively these contain the same data, but the two formats are
  209.     //    needed to make parsing easier.
  210.     //
  211.     string $cmd = "copyKeyCmd=";
  212.     $cmd = $cmd + "-animation objects ";
  213.  
  214.     //    Now assemble the options into a string to pass to animExport.
  215.     //    The > character will be replaced by a quotation mark in the 
  216.     //    AnimExport plug-in. This is required, since the translator option
  217.     //    box does not handle escaped quotation marks.
  218.     //
  219.     if ($whichRange == 2) {
  220.         $cmd = ( $cmd + "-time >" + $timeRange + "> ");
  221.         $cmd = ( $cmd + "-float >" + $timeRange + "> ");
  222.     }
  223.  
  224.     // If there's a time specified, always add the option
  225.     //
  226.     $cmd = ( $cmd + "-option " + $option + " " );
  227.  
  228.     if ($useChannelBox == 1) {
  229.         string  $main[];
  230.         string  $shape[];
  231.         string  $history[];
  232.         int     $i;
  233.         string  $attrs;
  234.  
  235.         catch( $main = `channelBox -q -sma mainChannelBox` );
  236.         catch( $shape = `channelBox -q -ssa mainChannelBox` );
  237.         catch( $history = `channelBox -q -sha mainChannelBox` );
  238.  
  239.         for( $i = 0; $i < size( $main ); $i++ ) {
  240.             $attrs = ( $attrs + "-at " + $main[$i] + " " );
  241.         }
  242.         for( $i = 0; $i < size( $shape ); $i++ ) {
  243.             $attrs = ( $attrs + "-at " + $shape[$i] + " " );
  244.         }
  245.         for( $i = 0; $i < size( $history ); $i++ ) {
  246.             $attrs = ( $attrs + "-at " + $history[$i] + " " );
  247.         }
  248.  
  249.         if( size( $attrs ) == 0 ) {
  250.             $cmd = "";
  251.             warning( "No channels selected in channel box" );
  252.         } else {
  253.             $cmd = ( $cmd +
  254.                 $attrs +
  255.                 "-hierarchy " + $hierarchy + " " );
  256.         }
  257.  
  258.         // Now add the specific objects from the channel box
  259.         //
  260.         string $objList[] = `channelBox -q -mainObjectList mainChannelBox`;
  261.         if ((size($main) > 0) && (size($objList) > 0))
  262.         {
  263.             for ($object in $objList)
  264.                 $cmd = $cmd + " " + $object;
  265.         }
  266.         $objList = `channelBox -q -shapeObjectList mainChannelBox`;
  267.         if ((size($shape) > 0) && (size($objList) > 0))
  268.         {
  269.             for ($object in $objList)
  270.                 $cmd = $cmd + " " + $object;
  271.         }
  272.         $objList = `channelBox -q -historyObjectList mainChannelBox`;
  273.         if ((size($history) > 0) && (size($objList) > 0))
  274.         {
  275.             for ($object in $objList)
  276.                 $cmd = $cmd + " " + $object;
  277.         }
  278.     } else {
  279.         $cmd = ($cmd +
  280.                 "-hierarchy " + $hierarchy + " " +
  281.                 "-controlPoints " + $doControlPoints + " " +
  282.                 "-shape " + $doShapes + " " );
  283.     }
  284.  
  285.     $opts += ";" + $cmd;
  286.  
  287.     return $opts;
  288. }
  289.  
  290. global proc animExportHelpPictures() {
  291.     int $doPictures = `checkBoxGrp -q -value1 helpPictures`;
  292.     if( $doPictures == 0 ) {
  293.         frameLayout -e -collapse yes methodPictureFrame;
  294.         return;
  295.     }
  296.  
  297.     int $method = `radioButtonGrp -q -select method`;
  298.  
  299.     string $methodPicture;
  300.  
  301.     if( $method == 1 ) {
  302.         $methodPicture = "CCPkeyframesOnly.xpm";
  303.     } else {
  304.         $methodPicture = "CCPcurveExact.xpm";
  305.     }
  306.  
  307.     picture -e -image $methodPicture methodPicture;
  308.     frameLayout -e -collapse no methodPictureFrame;
  309. }
  310.  
  311. global proc animExportWidgetsEnable()
  312. //
  313. // Description:
  314. //    These are the widgets that get enabled and
  315. //    disabled based on the certain states.  Put them
  316. //    here so they're all in one place.
  317. //    
  318. {
  319.     // Shapes and CVs checkboxes
  320.     //
  321.     int $enableIt = (( `radioButtonGrp -q -select channels` == 1 ) &&
  322.                      ( `radioButtonGrp -q -enable channels` ));
  323.     frameLayout -e -enable $enableIt attributesFrame;
  324.  
  325.  
  326.     // Start/End fields
  327.     //
  328.     $enableIt = (( `radioButtonGrp -q -select timeRange` == 2 ) &&
  329.                  ( `radioButtonGrp -q -enable timeRange` ));
  330.     frameLayout -e -enable $enableIt startEndFrame;
  331. }
  332.  
  333. proc string animExportWidgets( string $tabLayout)
  334. {
  335.     global int $gTextColumnWidthIndex;
  336.  
  337.     setParent $tabLayout;
  338.  
  339.     string $tabForm = `columnLayout -adjustableColumn true`;
  340.  
  341.     frameLayout -bv no -lv no -collapsable yes -collapse false
  342.         hierChanAttrFrame;
  343.  
  344.         columnLayout -adjustableColumn true;
  345.             radioButtonGrp
  346.                 -numberOfRadioButtons 2 
  347.                 -label "Hierarchy" 
  348.                 -label1 "Selected" 
  349.                 -label2 "Below" 
  350.                 -enable true
  351.                 hierarchy;
  352.  
  353.             radioButtonGrp
  354.                 -numberOfRadioButtons 2 -label "Channels" 
  355.                 -label1 "All Keyable" 
  356.                 -cc1 "animExportWidgetsEnable"
  357.                 -label2 "From Channel Box" 
  358.                 -cc2 "animExportWidgetsEnable"
  359.                 -enable true
  360.                 channels;
  361.         
  362.             frameLayout -bv no -lv no -collapsable no attributesFrame;
  363.                 columnLayout -adjustableColumn true;
  364.                     checkBoxGrp -label "Control Points" 
  365.                                 -ncb 1 -value1 off -l1 "" 
  366.                                 controlPoints;
  367.                     checkBoxGrp -label "Shapes" -ncb 1 
  368.                                 -value1 on -l1 "" shapes;
  369.                     setParent ..;
  370.                 setParent ..;
  371.         
  372.             separator -style "in" -w 1000;
  373.             setParent ..;
  374.         setParent ..;
  375.  
  376.     radioButtonGrp -numberOfRadioButtons 2 -label "Time Range" 
  377.         -label1 "All" 
  378.         -cc1 "animExportWidgetsEnable"
  379.         -label2 "Start/End" 
  380.         -cc2 "animExportWidgetsEnable"
  381.         timeRange;
  382.  
  383.     frameLayout -bv no -lv no -collapsable no startEndFrame;
  384.         columnLayout -adjustableColumn true;
  385.             floatFieldGrp -label "Start Time" -value1 0.0 frameStart;
  386.             floatFieldGrp -label "End Time" -value1 10.0 frameEnd;
  387.  
  388.             separator -style "in" -w 1000;
  389.     
  390.             checkBoxGrp -label "Help Images" -ncb 1 -value1 off -l1 "" 
  391.                 -cc1 "animExportHelpPictures;" 
  392.                 helpPictures;
  393.  
  394.             radioButtonGrp -numberOfRadioButtons 2 -label "Method" 
  395.                 -label1 "Keys" -cc1 "animExportHelpPictures"
  396.                 -label2 "Segments" -cc2 "animExportHelpPictures" method;
  397.  
  398.             frameLayout -bv no -lv no -collapsable yes -collapse yes 
  399.                 methodPictureFrame;
  400.                 columnLayout -columnAttach "left" $gTextColumnWidthIndex;
  401.                     picture methodPicture;
  402.                     setParent ..;
  403.                 setParent ..;
  404.                 
  405.             setParent ..;
  406.         setParent ..;
  407.  
  408.     return $tabForm;
  409. }
  410.  
  411. global proc int animExportOptions(     string $parent, 
  412.                                     string $action,
  413.                                     string $initialSettings, 
  414.                                     string $resultCallback )
  415. //
  416. //    Description:
  417. //        This script posts the anim export options.
  418. //
  419. //    Parameters:
  420. //        $parent    - the elf parent layout for this options layout. It is
  421. //                    always a scrollLayout.
  422. //        $action    - the action that is to be performed with this invokation
  423. //                    of this proc. Valid options are:
  424. //                        "query" - construct the options string and pass it
  425. //                                    to the resultCallback.
  426. //                        "post"    - post all the elf controls.
  427. //        $resultCallback    -
  428. //                This is the proc to be called with the result string. 
  429. //                resultCallback ( string $optionsString )
  430. //
  431. //    Returns:
  432. //        1 if successfull.
  433. //        0 otherwise.
  434. //
  435. {
  436.     int     $result;
  437.     string     $currentOptions;
  438.     string     $optionList[];
  439.     string     $optionBreakDown[];
  440.     int        $index;
  441.     
  442.     optionVar -intValue animExportAnimationFile true;
  443.  
  444.     if ($action == "post") {
  445.         setUITemplate -pushTemplate DefaultTemplate;
  446.         setParent $parent;
  447.  
  448.         columnLayout animExportMultiObjLayout;
  449.  
  450.             //    Make the layout invisible during the control creation.
  451.             //
  452.             columnLayout -e -vis false animExportMultiObjLayout;
  453.         
  454.             formLayout animExportForm;
  455.             rowColumnLayout -numberOfColumns 2 
  456.                         -rat 1 "top" 5
  457.                         -cal 1 "right" -cw 2 250 animExportFileOptsLayout;
  458.  
  459.             text -l "Precision";
  460.  
  461.             rowColumnLayout -numberOfColumns 2;
  462.  
  463.                 radioCollection animExportCollection;
  464.                 radioButton -label "Float (8)"
  465.                             -align "left" 
  466.                             -cl animExportCollection animExportFloatBtn;
  467.  
  468.                 text -l "";
  469.  
  470.                 radioButton -label "Double (17)"
  471.                             -align "left"
  472.                             -cl animExportCollection animExportDoubleBtn;
  473.  
  474.                 text -l "";
  475.  
  476.                 radioButton -label "Custom" -align "left"
  477.                             -onc "intField -e -en true animExportIntFld"
  478.                             -ofc "intField -e -en false animExportIntFld"
  479.                             -cl animExportCollection
  480.                             animExportCustomBtn;
  481.  
  482.                 intField     -min 1 -max 17 
  483.                             -s 1 -v 17 -en false animExportIntFld;
  484.                 setParent ..;
  485.  
  486.             text -l "File Contents";
  487.  
  488.             checkBox     -label "Use Node And Leaf Attribute Names"
  489.                         -v off animExportNodeChk;
  490.  
  491.             text -l "";
  492.  
  493.             checkBox     -label "Verbose Units" -align "left"
  494.                         -v off animExportVerboseChk;
  495.  
  496.             setParent ..;
  497.  
  498.             separator -style "in" -w 1000 animExportSep;
  499.  
  500.             formLayout -edit
  501.                 -attachForm animExportFileOptsLayout "top" 10
  502.                 -attachForm animExportFileOptsLayout "left" 65
  503.  
  504.                 -attachControl animExportSep "top" 5 animExportFileOptsLayout
  505.                 -attachForm animExportSep "left" 0
  506.                 -attachForm animExportSep "right" 0
  507.                 animExportForm;
  508.  
  509.             string $copyKeyTab = animExportWidgets("animExportMultiObjLayout");
  510.  
  511.             setParent ..;
  512.  
  513.         setUITemplate -popTemplate;
  514.  
  515.         //    Now to set the current settings.
  516.         //
  517.         $currentOptions = $initialSettings;
  518.         if (size($currentOptions) > 0) {
  519.             tokenize($currentOptions, ";", $optionList);
  520.             for ($index = 0; $index < size($optionList); $index++) {
  521.                 tokenize($optionList[$index], "=", $optionBreakDown);
  522.  
  523.                 if ($optionBreakDown[0] == "intValue") {
  524.                     int $intValue = $optionBreakDown[1];
  525.                         intField -edit -value $intValue animExportIntFld;
  526.                 } else if ($optionBreakDown[0] == "precision") {
  527.                     int $precision = $optionBreakDown[1];
  528.  
  529.                     if ($precision == 8) {
  530.                         radioCollection -edit -select animExportFloatBtn
  531.                                         animExportCollection;
  532.                     } else if ($precision == 17) {
  533.                         radioCollection -edit -select animExportDoubleBtn
  534.                                         animExportCollection;
  535.                     } else {
  536.                         radioCollection -edit -select animExportCustomBtn
  537.                                         animExportCollection;
  538.                         intField -edit -value $precision animExportIntFld;
  539.                     }
  540.                 } else if ($optionBreakDown[0] == "nodeNames") {
  541.                     int $value = $optionBreakDown[1];
  542.                     checkBox -e -v $value animExportNodeChk;
  543.                 } else if ($optionBreakDown[0] == "verboseUnits") {
  544.                     int $value = $optionBreakDown[1];
  545.                     checkBox -e -v $value animExportVerboseChk;
  546.                 } else {
  547.                     animExportSetup($optionBreakDown);
  548.                 }
  549.             }
  550.         }
  551.  
  552.         columnLayout -e -vis true animExportMultiObjLayout;
  553.  
  554.         $result = 1;
  555.     } else if ($action == "query") {
  556.         if (`radioButton -query -sl animExportFloatBtn`) {
  557.             $currentOptions += "precision=8";
  558.         } else if (`radioButton -query -sl animExportDoubleBtn`) {
  559.             $currentOptions += "precision=17";
  560.         } else if (`radioButton -query -sl animExportCustomBtn`) {
  561.             $currentOptions += 
  562.                 ("precision=" + `intField -q -value animExportIntFld`);
  563.         }
  564.  
  565.         $currentOptions += (";intValue="+`intField -q -value animExportIntFld`);
  566.         $currentOptions += (";nodeNames="+`checkBox -q -v animExportNodeChk`);
  567.         $currentOptions += 
  568.             (";verboseUnits="+`checkBox -q -v animExportVerboseChk`);
  569.  
  570.         $currentOptions += animExportGetOpts();
  571.     
  572.         eval($resultCallback+" \""+$currentOptions+"\"");
  573.  
  574.         $result = 1;
  575.     } else {
  576.         $result = 0;
  577.     }
  578.  
  579.     return $result;
  580. }
  581.